package teaching.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import teaching.pojo.PostMain;

import java.util.List;

/**
 * Author:20201002983_郑雨蓓
 * Date: 2024/4/15
 * Description:
 */
public interface PostMainMapper {
    @Select("SELECT pm.*, s.avatar AS avatar " +
            "FROM post_main pm " +
            "JOIN student s ON pm.student_username = s.username " +
            "WHERE pm.post_id = #{postId} " +
            "ORDER BY pm.id ASC")
        // ASC 表示升序排列，从低到高
    List<PostMain> getByPostId(Long postId);

    @Insert("INSERT INTO post_main(content, post_time, student_username, post_id) " +
            "VALUES( #{postMain.content}, #{postMain.postTime}, #{postMain.studentUsername}, #{postMain.postId})")
    int addPostMain(@Param("postMain") PostMain postMain);

}
